{{template "layout/layout_admin.html" .}}

{{define "style"}}

{{end}}

{{define "content"}}
<div class="layui-fluid main" style="margin:15px;">

    <fieldset class="layui-elem-field layui-field-title" style="margin-top:20px;">
        <legend>编辑业务线</legend>
    </fieldset>


    <form class="layui-form" method="post" action="{{urlfor "MainController.AppsEditDo"}}">
        <div class="layui-form-item">
            <label class="layui-form-label">业务线名称</label>
            <div class="layui-input-block" style="width:280px;">
                <input type="hidden" name="id" value="{{.info.Id}}">
                <input type="text" name="name" lay-verify="required" autocomplete="off" placeholder="填写业务线名称" class="layui-input" value="{{.info.Name}}">
            </div>
        </div>


        <div class="layui-form-item">
            <label class="layui-form-label">APPID</label>
            <div class="layui-input-block" style="width:280px;">
                <input type="text" name="appid" lay-verify="required|appid" autocomplete="off" placeholder="填写APPID" class="layui-input" value="{{.info.Appid}}">
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label">APP_KEY</label>
            <div class="layui-input-block" style="width:280px;">
                <input type="text" name="appkey" lay-verify="required|appkey" autocomplete="off" placeholder="填写APP_KEY" class="layui-input" value="{{.info.Appkey}}">
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label">绑定发件箱</label>
            <div class="layui-input-block" style="width:280px;">
                <select name="mid" lay-verify="required">
                    <option value="">请选择</option>
                {{range .allmails}}
                    <option value="{{.Id}}" {{if eq .Id $.info.Mid}}selected{{end}}>{{.Name}}({{.Account}})</option>
                {{end}}

                </select>
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label">说明</label>
            <div class="layui-input-block"  style="width:480px;">
                <textarea name="desc" class="layui-textarea" >{{.info.Desc}}</textarea>
            </div>
        </div>


        <div class="layui-form-item" style="margin-top:50px;">
            <div class="layui-input-block">
                <button class="layui-btn" lay-submit="" lay-filter="formSubmit">立即提交</button>
                <button type="reset" class="layui-btn layui-btn-primary" onclick="javascript:history.back();">返回</button>
            </div>
        </div>
    </form>

</div>
{{end}}
{{define "script"}}
<script>
    layui.use(['form', 'laydate','upload','element','table'], function() {
    {{template "layout/baseJs.html" .}}
        var form = layui.form
                ,layer = layui.layer
                ,laydate = layui.laydate
                ,element = layui.element
                ,$ = layui.jquery
                ,table = layui.table;



        form.verify({
            appid: function(value, item){
                if(! /^[a-zA-Z][a-zA-Z0-9_]{6,10}$/.test(value)){
                    return 'appid必须是5-10个字母开头的字符串';
                }
            },
            appkey: function(value, item){ //value：表单的值、item：表单的DOM对象

                if(! /\S{16,32}$/.test(value)){
                    return 'appkey必须是16-32个字符串';
                }
            }
        });

        form.on('submit(formSubmit)', function(data){
            var url = $(data.form).attr('action');
            var params = $(data.form).serialize();
            QI.ajaxForm(url, params);
            return false;
        });



    });
</script>
{{end}}